package com.woniu.order.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.order.infra.model.OrderEntry;
import com.woniu.order.infra.mapper.OrderEntryMapper;
import com.woniu.order.service.OrderEntryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.order.service.dto.OrderEntryDto;
import com.woniu.order.service.param.SearchOrderEntryServiceParam;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单条目表 服务实现类
 * </p>
 *
 * @author Lucas
 * @since 2022-11-26
 */
@Service
public class OrderEntryServiceImpl extends ServiceImpl<OrderEntryMapper, OrderEntry> implements OrderEntryService {

    /**
     * 根据订单Id、SkuId查询订单条目
     * @param searchOrderEntryServiceParam
     * @return
     */
    @Override
    public OrderEntryDto searchOrderEntry(SearchOrderEntryServiceParam searchOrderEntryServiceParam) {
        QueryWrapper<OrderEntry> qw = new QueryWrapper<>();
        qw.eq("order_id", searchOrderEntryServiceParam.getOrderId())
                .eq("sku_id",searchOrderEntryServiceParam.getSkuId());
        OrderEntry orderEntry = getOne(qw);
        OrderEntryDto orderEntryDto = BeanUtil.copyProperties(orderEntry, OrderEntryDto.class);
        return orderEntryDto;
    }

}
